package com.example.designpatterns.strategy;

public class CashContext {
    private CashStrategy cs = null;

    //简单工厂：将实例化具体策略从客户端放入Context类中
    public CashContext(String type) {
        switch (type) {
            case "正常收费":
                CashNormal cs0 = new CashNormal();
                cs = cs0;
                break;
            case "满300返100":
                CashRetrun cr1 = new CashRetrun(300, 100);
                cs = cr1;
                break;
            case "打8折":
                CashRebate cr2 = new CashRebate(0.8);
                cs = cr2;
                break;
        }

    }

    public double getResult(double money) {
        return cs.acceptCash(money);
    }

}